package users

import (
	"api/internal/respons"
	"context"
	"user_srv/userclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type EquityIncreaseLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewEquityIncreaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EquityIncreaseLogic {
	return &EquityIncreaseLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *EquityIncreaseLogic) EquityIncrease(req *types.EquityIncreaseRequest) (resp *types.Response, err error) {
	opinions, err := l.svcCtx.UserRpc.EquityIncrease(l.ctx, &userclient.EquityIncreaseRequest{
		LevelId:  req.LevelId,
		Benefits: req.Benefits,
	})
	if err != nil {
		return respons.Error(400, "权益增加失败", err.Error()), err
	}
	return respons.Success(opinions), nil
}
